import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-02-21
 * Time: 21:35
 */

class Student {
    private String id;

    public Student(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
public class Test {


    public static void main(String[] args) {
        // 如果使用TreeMap自定义类型不能比较的话，会报错
//        Map<Student,String> map = new TreeMap<>();
//        map.put(new Student("dsf"),"dfsf");
//        map.put(new Student("dsfsdff"),"dffdsfsf");

        HashBucket2<Student,String> hashBucket2 = new HashBucket2<>();
        hashBucket2.put(new Student("first"),"Fir");
        hashBucket2.put(new Student("second"),"Sco");
        hashBucket2.put(new Student("third"),"Thi");
        hashBucket2.put(new Student("forth"),"For");
        hashBucket2.put(new Student("fifth"),"Fif");
        hashBucket2.put(new Student("sixth"),"Six");
        hashBucket2.put(new Student("eighth"),"Eig");

        hashBucket2.put(new Student("fhges"),"Eig");

        System.out.println(hashBucket2.get(new Student("third")));


    }
}
